package org.example.config;

import org.example.quartz.job.DefaultJobManager;
import org.example.quartz.job.JobManager;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CoreConfig {
    @ConditionalOnClass({ StdSchedulerFactory.class, Scheduler.class })
    @Configuration
    public static class JobConfig {
        @Bean
        public JobManager defaultJobManager() throws SchedulerException {
            Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
            return new DefaultJobManager(defaultScheduler);
        }
    }

}
